package org.coral.server.game.module.${entity.getEntityName()?lower_case}.domain;

import org.coral.orm.core.annotation.PO;
import org.coral.orm.core.base.BasePo;

/**
* ${entity.getEntityName()}Po
* @author Jeremy
*/
public abstract class ${entity.getEntityName()}Po extends BasePo {

	<#-- Static Field -->
	<#if entityBeans ? exists>
	<#list entityBeans as bean>
	public static final String PROP_${bean.field ? upper_case} = "${bean.field}";
	</#list>
	</#if>
	
	<#-- filed -->
	<#if entityBeans ? exists>
	<#list entityBeans as bean>
	protected ${bean.type} ${bean.field};//${bean.desc}
	</#list>
	</#if>
	
	<#-- Constructor -->
	public ${entity.getEntityName()}Po(){
		<#if entityBeans ? exists>
		<#list entityBeans as bean>
		<#if bean.type == 'String'>
		this.${bean.field} = "";
		</#if>
		</#list>
		</#if>
	}
	
	<#-- Getter Setter-->
	<#if entityBeans ? exists>
	<#list entityBeans as bean>
	/** ${bean.desc} **/
	public ${bean.type} get${bean.field ? cap_first}(){
		return this.${bean.field};
	}
	
	public void set${bean.field ? cap_first}(${bean.type} ${bean.field}){
		this.${bean.field} = ${bean.field};
	}
	
	</#list>
	</#if>
	
	@Override
	public String toString() {
		return ${entity.genToStr()}
	}
	
	@Override
	public String[] props() {
		return new String[] {
		<#if entityBeans ? exists>
		<#list entityBeans as bean>
		"`${bean.field}`",
		</#list>
		</#if>
		};
	}

	@Override
	public Object[] propValues() {
		return new Object[] { 
		<#if entityBeans ? exists>
		<#list entityBeans as bean>
		get${bean.field ? cap_first}(),
		</#list>
		</#if>
		};
	}

	@Override
	public String[] indexs() {
		return new String[] {
			<#if indexs ? exists>
			<#list indexs as index>
			PROP_${index ? upper_case},
			</#list>
			</#if>
		};
	}
	
	@Override
	public Object[] indexValues() {
		return new Object[] {
			<#if indexs ? exists>
			<#list indexs as index>
			get${index?cap_first}(),
			</#list>
			</#if>
		};
	}
	
	@Override
	public String cacheId() {
		<#if entity.keysEmpty() >
		<#assign text="" />
		<#if indexs ? exists>
		<#list indexs as index>
		<#assign text += "get"+ index?cap_first+"()+\":\"+"/>
		</#list>
		return ${text?substring(0, text?length-5)};
		</#if>
		<#else>
		<#--retrn String.valueOf(get${primary?cap_first}());-->
		<#list primarys as primary>
		<#assign text += "get"+ primary?cap_first+"()+\":\"+"/>
		</#list>
		return ${text?substring(0, text?length-5)};
		</#if>
	}
	
	<#--
	@Override
	public Object key() {
		<#if entity.keysEmpty() >
		//主键为空,返回null
		return null;
		<#else>
		<#list primarys as primary>
		return get${primary?cap_first}();
		</#list>
		</#if>
	}

	@Override
	public String cacheId() {
		<#if entity.keysEmpty() >
		<#assign text="" />
		<#if indexs ? exists>
		<#list indexs as index>
		<#assign text += "get"+ index?cap_first+"()+\":\"+"/>
		</#list>
		return ${text?substring(0, text?length-5)};
		</#if>
		<#else>
		<#list primarys as primary>
		return String.valueOf(get${primary?cap_first}());
		</#list>
		</#if>
	}

	@Override
	public String keyColumn() {
		<#if entity.keysEmpty() >
		//主键为空,返回null
		return null;
		<#else>
		<#list primarys as primary>
		return PROP_${primary?upper_case};
		</#list>
		</#if>
	}-->
	
}
